package com.zyx.yygh.hosp.controller;

import com.zyx.yygh.common.result.Result;
import com.zyx.yygh.hosp.service.ScheduleService;
import com.zyx.yygh.model.hosp.Schedule;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author zyx
 * @version 1.0
 * @date 2022/1/21 021 17:11
 */

@RestController
@RequestMapping("/admin/hosp/schedule")
//@CrossOrigin
public class ScheduleController {

    @Resource
    private ScheduleService scheduleService;

    @ApiOperation(value = "查询排班的规则数据")
    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(@PathVariable long page,
                                  @PathVariable long limit,
                                  @PathVariable String hoscode,
                                  @PathVariable String depcode) {

        Map<String, Object> map = scheduleService.getRuleSchedule(page, limit, hoscode, depcode);

        return Result.ok(map);
    }

    @ApiOperation(value = "根据医院编号，科室编号和工作日期，查询排班详细信息")
    @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result getScheduleDetail(@PathVariable String hoscode,
                                    @PathVariable String depcode,
                                    @PathVariable String workDate){

        List<Schedule> list = scheduleService.getDetailSchedule(hoscode,depcode,workDate);
        return Result.ok(list);
    }
}
